cmake_minimum_required(VERSION 3.1)
cmake_policy(SET CMP0048 NEW)
project(ssserver VERSION 1.0.0.0)

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-unused-function -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast")

# options
include("Findlibev.cmake")
set (EXTRALIB ${LIBEV_LIBRARY})


include_directories("${CMAKE_CURRENT_BINARY_DIR}"
	"${PROJECT_BINARY_DIR}"
	"${LIBEV_INCLUDE_DIRS}"
	"${PROJECT_SOURCE_DIR}"
	"${PROJECT_SOURCE_DIR}/udns"
	)

set(SSSERVER
buffer.c
callback.c
help.c
logger.c
main.c
netutils.c
optparser.c
resolve.c
socks5.c
buffer2.c
user.c
http.c
dynctl.c
common.c
equipment.c
udns/udns_XtoX.c
udns/udns_bl.c
udns/udns_codes.c
udns/udns_dn.c
udns/udns_dntosp.c
udns/udns_init.c
udns/udns_jran.c
udns/udns_misc.c
udns/udns_parse.c
udns/udns_resolver.c
udns/udns_rr_a.c
udns/udns_rr_mx.c
udns/udns_rr_naptr.c
udns/udns_rr_ptr.c
udns/udns_rr_srv.c
udns/udns_rr_txt.c
)

set(SSSERVERCTL
dynctl_cli_ip.c
)

find_package(CURL)
set (EXTRALIB ${EXTRALIB} ${CURL_LIBRARIES})

set (STAGING_DIR $(STAGING_DIR))

# target
add_executable(ssserver ${SSSERVER})
target_link_libraries(ssserver ${EXTRALIB})
add_executable(ssserver_ctl ${SSSERVERCTL})

# install
install(TARGETS ssserver DESTINATION bin)
install(TARGETS ssserver_ctl DESTINATION bin)

include (InstallRequiredSystemLibraries)
SET(CPACK_GENERATOR "TBZ2" "DEB")
SET(CPACK_PACKAGE_CONTACT "ycsunjane@163.com")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "jianxi")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS "ON")

set (CPACK_PACKAGE_VERSION_MAJOR "2")
set (CPACK_PACKAGE_VERSION_MINOR "2")
set (CPACK_PACKAGE_VERSION_PATCH "2")

include (CPack)
